package com.mxdx.edu.common;

import java.io.Serializable;

/**
 * 统一规范化的api接口， 主要用于RestApi
 *
 * @param <T>
 * @author zhangyanchun
 *         2016年11月24日
 */
public class SpecApiResult<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    //模块名称
    private String apiName;
    // 响应时间
    private long timestamp = System.currentTimeMillis();
    // 响应码
    private String status = "20000601";
    // 请求序列码
    private String serialNum;
    // 响应描述（用户信息）
    private String message = "成功";
    // 描述信息（开发人员使用）
    private String info = "success";
    // 响应扩展
    private T result;
    //健康检查对象

    public SpecApiResult(String apiName,String status){
        this.apiName = apiName;
        this.status = status;
    }

    public SpecApiResult(){
    }
    
    private static SpecApiResult<String> healthApiResult = new SpecApiResult<>();

    public String getApiName() {
        return apiName;
    }

    public void setApiName(String apiName) {
        this.apiName = apiName;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getSerialNum() {
        return serialNum;
    }

    public void setSerialNum(String serialNum) {
        this.serialNum = serialNum;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    /**
     * 返回健康检查对象
     */
    public static SpecApiResult<String> getHealthApiResult(String status) {
        healthApiResult.setMessage("ok");
        healthApiResult.setStatus(status);
        return healthApiResult;
    }
}
